package org.example.elm_xiangmu.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.example.elm_xiangmu.po.Orders;

import java.util.List;

@Mapper
public interface OrdersMapper {
    @Insert("insert into orders (userId,businessId,orderDate,orderTotal,daId,orderState) values (#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},#{orderState})")
    @Options(useGeneratedKeys = true, keyProperty = "orderId")
    Integer createOrders(Orders orders);

    @Select("select * from orders where orderId = #{orderId}")
    Orders getOrdersById(Integer orderId);

    @Select("select * from orders where userId = #{userId}")
    List<Orders> listOrdersByUserId(String userId);

    @Select("select orderId from orders where orderDate = #{orderDate}")
    Integer getOrderIdByDate(String orderDate);
}
